package com.mushuilingfeng.ddd.user.domain.base;

import com.mushuilingfeng.ddd.user.domain.base.service.Ii8nService;
import com.mushuilingfeng.ddd.framework.factory.DomainServiceFactory;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author wx-laohongwei
 * @date 2024/9/19
 */
@Getter
@AllArgsConstructor
public class DomainArgumentException extends RuntimeException {
    private final int errorCode;
    private final String errorMsg;

    public DomainArgumentException(Ii8nCode ii8nCode) {
        this(-1, DomainServiceFactory.getDomainService(Ii8nService.class).getMessage(ii8nCode.getCode(), ii8nCode.getDefaultValue()));
    }

    public DomainArgumentException(String msg) {
        this.errorCode = -1;
        this.errorMsg = msg;
    }
}
